import dayjs, { Dayjs } from "dayjs";

export const utcdayjs = (date?: string | number | Dayjs | Date) => {
  return dayjs.utc(date).tz(dayjs.tz.guess());
};

export const utcdayjsFormat = (date?: string | number | Dayjs | Date) => {
  return utcdayjs(date).format("YYYY-MM-DD HH:mm:ss");
};

export const utcdayjsFormatDate = (date?: string | number | Dayjs | Date) => {
  return utcdayjs(date).format("YYYY-MM-DD");
};

/** 把 120 转成 2:00 */
export const formatSecondsToMinutesAndSeconds = (seconds: number) => {
  const minutes = Math.floor(seconds / 60);
  const remainingSeconds = seconds % 60;
  return `${minutes}:${remainingSeconds.toString().padStart(2, "0")}`;
};
